from util import *
from const import const

path = const.publicPath() + 'beacon/'

def main():
    time.sleep(2)
    util.logOut(__file__,'3次信标 开始')

    #返回主页面
    const.backMainProcess()
    #进入出击界面
    x, y = const.picLoop(const.publicPath() + 'bmp/weigh anchor.jpg')
    util.click(x, y)
    x, y, url = const.picMulLoop([
        path + 'operation.jpg', # 大世界
        const.publicPath() + 'bmp/withdraw.jpg', # 在图里
    ])
    if url == path + 'operation.jpg':
        pass
    elif url == const.publicPath() + 'bmp/withdraw.jpg':
        util.click(x, y)
        x, y = const.picLoop(const.publicPath() + 'bmp/OK.jpg')
        util.click(x, y)
        const.backMainProcess()
        x, y = const.picLoop(const.publicPath() + 'bmp/weigh anchor.jpg')
        util.click(x, y)
        x, y = const.picLoop(path + 'operation.jpg')
    util.click(x, y)
    x, y = const.picLoop(path + 'overview.jpg')
    time.sleep(2)
    util.click(x, y)
    x, y = const.picLoop(path + 'ash.jpg')
    time.sleep(2)
    util.click(x, y)

    x, y, url = const.picMulLoop([
        const.publicPath() + 'beacon/is_beaconMETA.jpg', # 正常进入的界面
        const.publicPath() + 'beacon/beacon list.jpg', # 未打完蓝色
        const.publicPath() + 'beacon/beacon list2.jpg', # 未打完棕色
    ])
    if url == const.publicPath() + 'beacon/is_beaconMETA.jpg':
        pass
    elif url == const.publicPath() + 'beacon/beacon list.jpg':
        # 打完蓝色先
        const.beaconProcess('blue', skipIntelligence=True)
    elif url == const.publicPath() + 'beacon/beacon list2.jpg':
        # 打完棕色先
        const.beaconProcess('brown', skipIntelligence=True)

    const.picLoop(const.publicPath() + 'beacon/is_beaconMETA.jpg')

    util.click(300, 300) # 左边那个
    x, y = const.picLoop(path + 'beacon list.jpg')
    util.click(x, y)
    const.picLoop(path + 'batile start.jpg')

    # 判断还剩几次
    cnt = 3 # 默认三次
    list = util.getNumbers((691, 18, 717, 34))
    if len(list) > 0:
        cnt = int(list[0][0])
        util.logOut(__file__,'需要执行'+str(cnt)+'次')

    for n in range(cnt):
        util.logOut(__file__,'------------一把开始-----------')
        x, y = const.picLoop(path + 'batile start.jpg')
        util.click(x, y)

        x, y, url = const.picMulLoop([
            const.publicPath() + 'bmp/anchor.bmp', # 正常出击
            const.publicPath() + 'bmp/quit.jpg', # 自律 今日不再提示
        ])
        if url == const.publicPath() + 'bmp/anchor.bmp':
            pass
        elif url == const.publicPath() + 'bmp/quit.jpg':
            util.click(x, y)
            util.logOut(__file__,'今日不再提示')

        x, y = const.picLoop(path + 'weigh anchor.jpg')
        util.click(x, y)
        x, y = const.picLoop(const.publicPath() + 'bmp/get_items.bmp')
        util.click(x, y)
        const.picLoop(path + 'complete.jpg')
        # 确定按钮变成了半透明，这个是确定按钮的位置
        util.click(736, 450)
        util.logOut(__file__,'------------一把结束-----------')
        
    #返回主页面
    time.sleep(2)
    const.backMainProcess()